package org.misalen.web.admin.controllers;

import org.misalen.web.admin.util.ServerResult;
import org.misalen.web.database.model.mysql.pro.ProVideoReward;
import org.misalen.web.database.repository.mysql.ProVideoRewardRepository;
import org.misalen.web.database.util.PaginationFrom;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping(value = "/pro-video-reward")
public class ProVideoRewardController extends BaseController {

	@Autowired
	protected ProVideoRewardRepository proVideoRewardRepository;

	/**
	 * 列表页
	 * 
	 * @return 列表目标页
	 */
	@RequestMapping(value = "/{primaryKey}", method = { RequestMethod.GET })
	public ModelAndView list(@PathVariable(value = "primaryKey") String videoId) {
		ModelAndView modelAndView = new ModelAndView("/proVideoReward/list");
		modelAndView.addObject("videoId", videoId);
		return modelAndView;
	}

	/**
	 * 列表
	 * 
	 * @param 搜索条件
	 * @param 分页/排序条件
	 * @return 查询结果
	 */
	@RequestMapping(value = "/", method = { RequestMethod.POST })
	public @ResponseBody ServerResult listPost(String videoId, PaginationFrom<ProVideoReward> pagination) {
		PaginationFrom<ProVideoReward> from = proVideoRewardRepository.terminalList(videoId, pagination);
		return renderSuccess(from);
	}

	/**
	 * 删除终端
	 * 
	 * @param
	 */
	@RequestMapping(value = "/delterminal/{primaryKey}", method = { RequestMethod.POST })
	public @ResponseBody ServerResult delterminal(@PathVariable String primaryKey) {
		// TODO 刪除终端
		return renderSuccess();
	}

	/**
	 * 收回红包
	 * 
	 * @param 信息
	 * @return 更新后的信息
	 */
	@RequestMapping(value = "/rake/{primaryKey}", method = { RequestMethod.POST })
	public @ResponseBody ServerResult rake(@PathVariable String primaryKey) {
		// TODO 收回红包
		return renderSuccess();
	}
}
